package cn.wolfcode.trip.base.service.impl;

import cn.wolfcode.trip.base.domain.SeeAll;
import cn.wolfcode.trip.base.mapper.SeeAllMapper;
import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.ISeeAllService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class SeeAllServiceImpl implements ISeeAllService {

    @Autowired
    private SeeAllMapper seeAllMapper;

    @Override
    public PageInfo<SeeAll> query(QueryObject qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        List<SeeAll> list = seeAllMapper.selectForList(qo);
        return new PageInfo<>(list);
    }

    @Override
    public void saveOrUpdate(SeeAll entity) {
        if (entity.getId() != null){
            seeAllMapper.updateByPrimaryKey(entity);
        }else {
            seeAllMapper.insert(entity);
        }
    }
}
